package com.nie.mybatisPlus.generator.system.context;

/**
 * 基地环境处理程序
 *
 * @author nie_cq
 * @date 2022/11/23
 */
public class BaseContextHandler {

    private static final ThreadLocal<String> THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置租户
     *
     * @param tenantId 承租者id
     */
    public static void setTenant(String tenantId) {
        THREAD_LOCAL.set(tenantId);
    }

    /**
     * 获取租户id
     *
     * @return {@code String}
     */
    public static String getTenantId() {
        return THREAD_LOCAL.get();
    }

    /**
     * 清晰
     */
    public static void clear() {
        THREAD_LOCAL.remove();
    }
}
